<template>
    <div class="execution">
        <basic-container>
            <avue-crud ref="crud"
                       :page.sync="page"
                       :data="tableData"
                       :table-loading="tableLoading"
                       :option="tableOption"
                       @on-load="getList"
                       @search-change="searchChange"
                       @refresh-change="refreshChange">
                <template slot="menuRight">
                    <el-button type="primary" icon="el-icon-edit"  size="small" @click="jumpToAdd">新增</el-button>
                </template>
                <template slot-scope="scope" slot="menu">
                    <el-button type="text"
                               size="small"
                               plain
                               @click="jumpToEdit(scope.row)">编辑</el-button>
                    <!--<el-button type="text"-->
                               <!--size="small"-->
                               <!--plain-->
                               <!--@click="jumpToDetail(scope.row)">详情</el-button>-->
                </template>
                <template slot-scope="scope" slot="passportId">
                    <el-tag v-if="scope.row.passportId">是</el-tag>
                    <el-tag v-else>否</el-tag>
                </template>
                <template slot-scope="scope" slot="userId">
                    <el-tag v-if="scope.row.userId">是</el-tag>
                    <el-tag v-else>否</el-tag>
                </template>
            </avue-crud>
        </basic-container>
    </div>
</template>
<script>
    import{
        tableOption
    } from "../../../const/crud/scm/purchase/purchaseemployee";
    import{
        fetchList,
    } from "../../../api/purchase/purchaseemployee";
    import {
        filterForm
    }from '@/util/util';
    export default {
        name: "index",
        data (){
            return {
                tableData: [],
                page: {
                    total: 0, // 总页数
                    currentPage: 1, // 当前页数
                    pageSize: 20 // 每页显示多少条
                },
                tableLoading: false,
                tableOption:tableOption
            }
        },
        methods:{
            getList(page, params) {
                this.tableLoading = true
                fetchList(Object.assign({
                    current: page.currentPage,
                    size: page.pageSize
                }, params)).then(response => {
                    this.tableData = response.data.data.records
                    this.page.total = response.data.data.total
                    this.tableLoading = false
                })
            },
            jumpToAdd() {
                this.$router.push({path:'/purchase_employee/add'})
            },
            jumpToEdit(row){
                this.$router.push({path:'/purchase_employee/edit',query:row})
            },
            jumpToDetail(row){
                this.$router.push({path:'/purchase_employee/detail',query:row})
            },
            /**
             * 搜索回调
             */
            searchChange(form, done) {
                this.getList(this.page, form);
                done();
            },
            /**
             * 刷新回调
             */
            refreshChange(info) {
    this.getList(this.page, this.filterForm(info.searchForm));
},
        }
    }
</script>

<style scoped lang="scss">
    .searchBox{
        margin: 20px 0;
        .inputStyle{
            width: 20%;
        }
        .addBtn{
            margin-left: 20px;
        }
    }

</style>
